import { ajax } from "../../public/promiseAjax.js";
import * as obj from "../public.js";
import { cookie } from "../../public/cookieFnNew.js"
const o = obj.default;
function loginC() {
  const tel = o.$('.tel').value;
  const code = o.$('.have').nextElementSibling.value;
  ajax({
    url: 'http://localhost:3000/loginCode',
    method: 'post',
    data: {
      tel,
      code
    }
  }).then(res=>{
    const data = JSON.parse(res)
    if(data.code === 0){
      alert(data.msg)
    }else{
      const d = data.data
      cookie.setCookie('petUserD',`nickName:${d.nickName},tel:${d.tel},username:${d.username}`)
      location.href = './index.html';
    }
  })


}




export { loginC }